import http from '@/api';
import { ADMIN_MODULE } from '@/api/helper/prefix';
import type { IPage } from '@/api/types';
import type { VehicleInfoQuery, VehicleInfoRow, VehicleInfoForm } from '@/api/types/vehicleinfo/vehicleInfo';
import type { UploadRawFile } from 'element-plus/es/components/upload/src/upload';
import type { AxiosRequestConfig } from 'axios';

/**
 * 查询列表
 * @param params
 * @returns {*}
 */
export const getVehicleInfoListApi = (params: VehicleInfoQuery) => {
  return http.get<IPage<VehicleInfoRow>>(ADMIN_MODULE + `/vehicle-info`, params);
};

/**
 * 添加
 * @param params
 * @returns {*}
 */
export const createVehicleInfoApi = (params: VehicleInfoForm) => {
  return http.post(ADMIN_MODULE + `/vehicle-info`, params);
};

/**
 * 修改
 * @param params
 * @returns {*}
 */
export const updateVehicleInfoApi = (params: VehicleInfoForm) => {
  return http.put(ADMIN_MODULE + `/vehicle-info`, params);
};

/**
 * 删除
 * @param params
 * @returns {*}
 */
export const removeVehicleInfoApi = (params: { ids: (string | number)[] }) => {
  return http.delete(ADMIN_MODULE + `/vehicle-info`, params);
};

/**
 * 获取详情
 * @param params
 * @returns {*}
 */
export const getVehicleInfoDetailApi = (params: { id: number }) => {
  const { id } = params;
  return http.get<VehicleInfoRow>(ADMIN_MODULE + `/vehicle-info/${id}`);
};

/**
 * 导入excel
 * @param params
 */
export const importVehicleInfoExcelApi = (params: UploadRawFile, config?: AxiosRequestConfig<any> | undefined) => {
  return http.upload(ADMIN_MODULE + `/vehicle-info/import`, params, config);
};

/**
 * 导出excel
 * @param params
 * @returns {*}
 */
export const exportVehicleInfoExcelApi = (params: VehicleInfoQuery) => {
  return http.download(ADMIN_MODULE + `/vehicle-info/export`, params);
};

/**
 * list
 */
export const getVehicleInfoListNopApi = (params: VehicleInfoQuery) => {
  return http.get<VehicleInfoRow>(ADMIN_MODULE + `/vehicle-info/listNop`, params);
};
